package com.honeywen.mymvc.opera;

import java.util.Objects;

/**
 *
 * @author wangwei
 * @date 2019/8/15
 */
public class Test4 {


    public static boolean isRationalEqual(String S, String T) {


        if (S == null || T == null) {
            return false;
        }
        if (S.length() == 0 || T.length() == 0) {
            return false;
        }

        if (S.contains("(") && !T.contains("(")) {
            return false;
        }
        if (!S.contains("(") && T.contains("(")) {
            return false;
        }

        if (!S.contains("(") && !T.contains("(")) {
            return Objects.equals(S, T);
        }


        int s1 = S.indexOf("(");
        int s2 = S.indexOf(")");
        String repeat1 = S.substring(s1 +1, s2);

        int t1= T.indexOf("(");
        int t2 = T.indexOf(")");
        String repeat2 = T.substring(t1 + 1, t2);


        System.out.println(repeat1);
        System.out.println(repeat2);

        // 转换
        String s = S.substring(0, s1);
        String t = T.substring(0, t1);


        String sn = s + repeat1 + repeat1;
        String tn = t + repeat2 + repeat2;


        return true;

    }


    public static void main(String[] args) {

        System.out.println(isRationalEqual("0.(52)", "0.5(25)"));
    }
}
